package com.edu.solr_news.dao;
import com.edu.solr_news.bean.DataModel;
import com.edu.solr_news.bean.News;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface NewsDao {



   //首页词云生成
   @Select("select content from xinwen where time>=#{starttime} and time<=#{endtime}")
   public List<String> findContent(String starttime,String endtime);

   //首页地图数据加载
   @Select("select count(id) as value,country as name from xinwen where time>=#{starttime} and time<=#{endtime} group by country")
   public List<DataModel> countNum( String starttime,String endtime);

   //数据总量返回
   @Select("select count(id) from xinwen")
   public int findNewsCount();

   //热点推荐
   @Select("select *from xinwen order by onclick desc limit #{page}, #{limit}")
   public List<News> findByOnclick(int page,int limit);

   //更新点击量
   @Update("update xinwen set onclick=#{onclink} where id=#{id}")
   public void updateOnclick(String id,int onclink);

   //查询点击量
   @Select("select onclick from xinwen where id=#{id}")
   public int findOnclick(String id);

   //查询指定新闻
    @Select("select * from xinwen where id=#{id}")
    public News findNewsById(String id);

}
